package com.webdemo11.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.webdemo11.pojo.User;
import com.webdemo11.service.UserService;

public class QueryUser extends HttpServlet {
	private static final long serialVersionUID = 1L;
    private UserService userService;
    
	public UserService getUserService() {
		return userService;
	}

	public void setUserService(UserService userService) {
		this.userService = userService;
	}

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doPost(request,response);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		List<User> users = userService.getUsers();
		request.setAttribute("users", users);
		request.getRequestDispatcher("/WEB-INF/jsp/show.jsp").forward(request, response);
	}
}
